-
-
Notifications
You must be signed in to change notification settings - Fork 82
[DiscordRPC] Fix non-functioning global toggle #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Bagus Nur Listiyono <[email protected]>
Signed-off-by: Bagus Nur Listiyono <[email protected]>
|
@sentry review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all should be good except for those request changes below.
CollapseLauncher/Classes/DiscordPresence/DiscordPresenceManager.cs
Outdated
Show resolved
Hide resolved
Use direct assignment to field and use implicit cast instead of ToBoolNullable() as the boolean will return false as default value afterwards.
| private int barWidth; | ||
| private int consoleWidth; | ||
|
|
||
| private readonly bool IsRpcEnabled_QS = AppDiscordPresence?.IsRpcEnabled ?? false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The readonly field IsRpcEnabled_QS is initialized with a stale false value because AppDiscordPresence is null during HomePage construction, permanently disabling the RegionRpcToggle.
Severity: HIGH | Confidence: High
🔍 Detailed Analysis
The readonly field IsRpcEnabled_QS in HomePage.xaml.cs is initialized at a point in the application startup sequence where AppDiscordPresence is still null. This causes the field to be permanently set to false due to the null-coalescing operator (?? false). The UI's RegionRpcToggle is bound to this readonly field, and as a result, it will always be disabled. This prevents users from interacting with the regional RPC toggle, even when the global RPC setting is enabled, which defeats the purpose of the new control.
💡 Suggested Fix
Instead of using a readonly field, convert IsRpcEnabled_QS into a property with a getter that dynamically reads the current state from AppDiscordPresence.IsRpcEnabled. This ensures the UI binding always reflects the up-to-date value of the global RPC setting. Also, consider implementing INotifyPropertyChanged to update the UI dynamically if the global setting can change while the page is open.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs#L82
Potential issue: The `readonly` field `IsRpcEnabled_QS` in `HomePage.xaml.cs` is
initialized at a point in the application startup sequence where `AppDiscordPresence` is
still `null`. This causes the field to be permanently set to `false` due to the
null-coalescing operator (`?? false`). The UI's `RegionRpcToggle` is bound to this
`readonly` field, and as a result, it will always be disabled. This prevents users from
interacting with the regional RPC toggle, even when the global RPC setting is enabled,
which defeats the purpose of the new control.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 513280
# What's changed? - 1.83.14 - **[New]** Allow game process to be run as child process of Collapse, by @gablm - This allows stuff like Steam Overlay/controls to work. - User can enable it under Game Settings -> Advanced Settings. - **[New]** [ZZZ] DirectX 12 and Ray Tracing experimental settings, by @neon-nyan - User can use DirectX 12 and RT/Upscaling in-game natively. You will need to enable the DirectX 12 option under game settings. - Availability of certain options depends on the system you are running on. - Do note that the game **MIGHT stutter** on any new scene/sprite loads, and depending on your system it might be slow/fast. - The longer you play, the stutter should go away. - Ray tracing comparison: #853 (comment) - **[Fix]** Misc settings not loading, by @gablm - This affected stuff like Advanced game settings, command line, etc - **[Imp]** Reduce CPU usage in Discord RPC module, by @neon-nyan - More details: #845 - **[Fix]** Plugin news not reloaded on page/region refresh, by @gablm - **[Fix]** [ZZZ] Game Settings reset after using Collapse' GSP, by @shatyuka - **[Fix]** Discord RPC did not get disabled globally, by @bagusnl @neon-nyan - More details: #849 - **[Fix]** HSR Repair/Cache update method, by @neon-nyan - More details: #852 - TL;DR: Completely rewritten - **[Fix]** Sophon not resuming update, by @neon-nyan - After cancelling/pausing game update, the launcher should now perform checks on which assets already updated so only the necessary files are getting downloaded. - **[Fix]** [ZZZ] Deleted assets gets redownloaded on update, by @neon-nyan - More details: #854 - **[Fix]** Game update does not work on games without separate audio package, by @gablm - **[Fix]** Playtime counter not stopped after user switched game/region mid-session, by @gablm - **[Fix]** Directory might not get created when updating game through Sophon, by @neon-nyan - **[Fix]** Main Page's Carousel did not get stopped/paused when told to, by @bagusnl - Carousel now should get paused if you sent Collapse to tray or when Collapse is not on the foreground. - This is interim fix while the whole background subsystem is getting rewritten by @neon-nyan. - More details: #846 ### Templates <details> <summary>Changelog Prefixes</summary> ``` **[New]** **[Imp]** **[Fix]** **[Loc]** **[Doc]** ``` </details>
Main Goal
Fix global RPC toggle not actually disabling RPC.
Also disable RPC regional setting when global toggle is set to disabled.
Closes #806
PR Status :
Templates
Changelog Prefixes